package com.fhb.java.d20250609.枚举;

import org.junit.Test;

/**
 * @author abao
 * @Description TODO
 * @createTime 2025-06-09 19:50:00
 */
public class 枚举定义方法测试 {

    enum Operation{

        ADD{
            @Override
            double operate(double x, double y) {
                return x + y;
            }
        },

        SUBTRACT{
            @Override
            double operate(double x, double y) {
                return x =y;
            }
        },

        MULTIPLY{
            @Override
            double operate(double x, double y) {
                return x * y;
            }
        },

        DIVIDE{
            @Override
            double operate(double x, double y) {
                return x/y;
            }
        }

        ;

        abstract double operate(double x, double y);

    }


    @Test
    public void test(){

        double x = 10;
        double y = 2;


        System.out.println(Operation.ADD.operate(x,y));
        System.out.println(Operation.SUBTRACT.operate(x,y));
        System.out.println(Operation.MULTIPLY.operate(x,y));
        System.out.println(Operation.DIVIDE.operate(x,y));
        /**
         * 12.0
         * 2.0
         * 20.0
         * 5.0
         */


    }

}
